<?php
include ("../../inc/global.inc");
include("../islogin.php");
if($_POST[tj_act]){
    $rs=@mysql_query("select * from member where m_user='$_POST[cz_name]'");
	$row=@mysql_fetch_array($rs);
	if($row['id']){
	   if($_POST[j_type]==2){
	   //充值
	   
	   $jifen=$row[m_jifen]+$_POST[cz_num];
	   @mysql_query("update member set m_jifen='$jifen' where id='".$row['id']."'");
	   @mysql_query("insert into jifen (member_id,j_type,j_num,j_name,add_time) values ('".$row['id']."','$_POST[j_type]','$_POST[cz_num]','$_POST[cz_type]','".date("Y-m-d H:i:s")."')");
	   
	   }else{
	   //消费
	   $jifen=$row[m_jifen]-$_POST[cz_num];
	   @mysql_query("update member set m_jifen='$jifen' where id='".$row['id']."'");
	   @mysql_query("insert into jifen (member_id,j_type,j_num,j_name,add_time) values ('".$row['id']."','$_POST[j_type]','$_POST[cz_num]','$_POST[cz_type]','".date("Y-m-d H:i:s")."')");
	   }
	   
	
	echo "<script>alert('充值成功');location='add.php';</script>";
	}else{
	echo "<script>alert('账号错误');location='add.php';</script>";
	}
}
?>
<HTML>
<HEAD>
<TITLE>admin</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<LINK href="../css/css.css" rel=stylesheet>
<script type='text/javascript' src="../js/islogin.js" charset="gb2312"></script>
</HEAD>
<BODY>
<center>
  <table width="700" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <tr>
      <td height="25" bgcolor="#EEEEF9" style="padding-left:5px;">三帝币充值&nbsp;&nbsp;<a href="javascript:history.go(-1)">返回</a></td>
    </tr>
  </table>
 <table width="700" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#000000" >
<form action="" method="post" name="form1" onSubmit="return check()">
	<tr align='center' bgcolor='#D8EAF4'>
	  <td height="35" colspan="2" valign="middle" nowrap bgcolor="#8DA8CF" class='category'><span style="padding-left:5px;">三帝币充值</span></td>
	</tr>
<tr align='center' bgcolor='#FFFFFF'>
  <td width="162" align="center" bgcolor="#8DA8CF">会员账号</td>
  <td width="519" align="left" bgcolor="#FFFFFF" style="padding-left:5px"><input name="cz_name" type="text" id="cz_name" size="20"></td>
</tr>
<tr align='center' bgcolor='#FFFFFF'>
  <td align="center" bgcolor="#8DA8CF">充值数据</td>
  <td align="left" bgcolor="#FFFFFF" style="padding-left:5px"><input name="cz_num" type="text" id="cz_num" size="20" maxlength="20">限数字</td>
</tr>
<tr align='center' bgcolor='#FFFFFF'>
  <td align="center" bgcolor="#8DA8CF">充值类型</td>
  <td align="left" bgcolor="#FFFFFF" style="padding-left:5px"><input name="j_type" type="radio" value="2" checked>
    充值&nbsp;&nbsp;<input type="radio" name="j_type" value="1">消费</td>
</tr>
<tr align='center' bgcolor='#FFFFFF'>
  <td align="center" bgcolor="#8DA8CF">充值类型</td>
  <td align="left" bgcolor="#FFFFFF" style="padding-left:5px"><input name="cz_type" type="text" id="cz_type" value="充值" size="20" maxlength="20"></td>
</tr>
  <tr align='center' bgcolor='#FFFFFF'><input type="hidden" name="tj_act" value="ok">
  <td colspan="2"><input type="submit" value="添加"></td>
  </tr>
  </form>
</table>
</center>
</BODY>
</HTML>

<script language="javascript">
function $(id){
return document.getElementById(id);
}
function check(){
if($("cz_name").value==""){
alert("账号能为空");
$("cz_name").focus();
return false;
}
var num = parseInt(document.form1.cz_num.value); 
if(isNaN(num)){
alert("请输入数字"); 
return false; 
}
}
</script>